package com.yanqu.road.entity.wingroom;

import com.yanqu.road.entity.DataObject;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author ：zfr
 * @date ：2022/1/19 15:03
 *  玩家厢房数据
 */
public class UserWingRoomData extends DataObject {
    //玩家id
    private long userId;
    //厢房等级(徽章)
    private int lv;
    //厢房区域列表
    private Map<Integer, WingRoomRegion> regionMap = new ConcurrentHashMap<>();
    //厢房舒适度 实时计算
    private long comfortValue;
    //领取呼朋唤友奖励次数
    private int getEventRewardTimes;
    //预领取呼朋唤友奖励次数
    private int preGetEventRewardTimes;
    //领奖次数刷新时间
    private long timesResetTime;
    //背景音乐
    private String bgm = "0";

    public UserWingRoomData() {
    }

    public UserWingRoomData(long userId, long resetTime, short option) {
        this.userId = userId;
        this.timesResetTime = resetTime;
        this.lv = 1;
        this.setOp(option);
    }

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        this.userId = userId;
    }

    public int getLv() {
        return lv;
    }

    public void setLv(int lv) {
        if (this.lv != lv) {
            this.lv = lv;
            setUpdateOption();
        }
    }

    public Map<Integer, WingRoomRegion> getRegionMap() {
        return regionMap;
    }

    public void setRegionMap(Map<Integer, WingRoomRegion> regionMap) {
        this.regionMap = regionMap;
        setUpdateOption();
    }

    public long getComfortValue() {
        return comfortValue;
    }

    public void setComfortValue(long comfortValue) {
        if (this.comfortValue != comfortValue) {
            this.comfortValue = comfortValue;
            setUpdateOption();
        }
    }

    public int getGetEventRewardTimes() {
        return getEventRewardTimes;
    }

    public void setGetEventRewardTimes(int getEventRewardTimes) {
        if (this.getEventRewardTimes != getEventRewardTimes) {
            this.getEventRewardTimes = getEventRewardTimes;
            setUpdateOption();
        }
    }

    public int getPreGetEventRewardTimes() {
        return preGetEventRewardTimes;
    }

    public void setPreGetEventRewardTimes(int preGetEventRewardTimes) {
        this.preGetEventRewardTimes = preGetEventRewardTimes;
    }

    public long getTimesResetTime() {
        return timesResetTime;
    }

    public void setTimesResetTime(long timesResetTime) {
        if (this.timesResetTime != timesResetTime) {
            this.timesResetTime = timesResetTime;
            setUpdateOption();
        }
    }

    public void addRegion(WingRoomRegion region) {
        if (!regionMap.containsKey(region.getRegionId())) {
            regionMap.put(region.getRegionId(), region);
            setUpdateOption();
        }
    }

    public int getTotalGetEventRewardTimes() {
        return getEventRewardTimes + preGetEventRewardTimes;
    }

    public String getBgm() {
        return bgm;
    }

    public void setBgm(String bgm) {
        if(!Objects.equals(bgm, this.bgm)) {
            this.bgm = bgm;
            setUpdateOption();
        }
    }
}
